home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Pascal / Utilities / Snippets / README about mk < prev    next >
Encoding:
Text File  |  1992-01-19  |  2.7 KB  |  99 lines  |  [TEXT/MPS ]

  1. MK
  2. ==
  3.  
  4. A template maker. © G. Sawitzki 1988, 1992                                    
  5.  
  6. Syntax: mk  [-v] [-<type>] <name> <var list>
  7. The interpretation of parameters is position dependent.
  8.  
  9.     -v            verbose
  10.     -<type>        admissible types depend on templates loaded in resource branch.
  11.                 Type mk to see a list of the templates installed ant their parameters.
  12.     <name>        Base name of the file to be generated. Extension depends on <type>.
  13.     <var list>    strings to be used for substitution.
  14.     
  15.     
  16. A file <name>.<extension> is generated and filled with the information of <type>, where
  17. the strings in <var list> are substituted in a <type> template.
  18. "Open <name>.<extension>" is written to diagnostic.
  19.  
  20.  
  21.  
  22. Error conditions:
  23.  
  24.     (1)    Syntax error
  25.     (2)    Expanded template too big
  26.     (3)    Resource branch corrupt.
  27. mk (without any parameters) will dump a list of the available templates, 
  28. together with their parameters.    
  29.  
  30.     
  31. Operation:
  32.  
  33. mk looks for a string list with name <type> in its resource fork. This string list is
  34. interpreted as follows:
  35.     string 1: file extension for a file to create. mk creates <name>.<extension>
  36.     string 2: name of a TEXT resource to use as a template.
  37.     string 3ff: strings to be substituted in template.
  38.         <name> is substituted for the first string in the string list
  39.         subsequent parameters of the var list are substituted by order.
  40.         
  41. String list 128 is used as a default if no <type> is given.
  42.  
  43.  
  44. Templates installed in the distribution version are:
  45.     
  46.     -prog        MPW Pascal Program (default)
  47.     -unit        MPW Pascal Unit
  48.     -tool        MPW Pascal Tool.
  49.     
  50. Examples:
  51.     mk                # gives an error message, and a list of available templates
  52.     mk test            # generates a program code template called test.p
  53.     mk -tool myTool    # generates a code template myTool.p for a tool
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60. 3.12.1988    gs    
  61. =============
  62. 19. 1. 1992 moved resources to .rsrc file, discarded templates in .r file.
  63.     TEXT resources are now supported by ResEdit, so templates can be accessed by ResEdit.
  64.     
  65.  
  66. To generate a new resource file from templates stored in text files, use
  67. Rez with a script like in the following example:
  68. #include "Types.r"
  69. /* 
  70. Resources for make
  71.     STR# resource name is the name of a type
  72.     first entry in STR# is the file extension for the file to create,
  73.     second entry is the name of a TEXT resource.
  74.     The following entries are strings to be substituted
  75.     by position.
  76. */
  77.  
  78. /* default list. must have id 128 */
  79. resource 'STR#' (128, "MAIN", preload) {
  80.     {    ".p","PROG","program_name"}
  81. };
  82.  
  83. /* other lists */
  84. resource 'STR#' (23542, "tool", preload) {
  85.     {    ".p","TOOL","tool_name"}
  86. };
  87.  
  88. resource 'STR#' (27045, "unit", preload) {
  89.     {    ".p","UNIT","unit_name"}
  90. };
  91.  
  92. resource 'STR#' (25441, "prog", preload) {
  93.     {    ".p","PROG","program_name"}
  94. };
  95.  
  96. read 'TEXT'  (256,"PROG") "prog.text";
  97. read 'TEXT' (257,"UNIT") "unit.text";
  98. read 'TEXT' (258,"TOOL") "tool.text";
  99.